package one.stand.enums;

import lombok.Data;

/**
 * @author luoyang
 * @date 2020/4/29 10:24
 */

public enum CouponStateEnums {
//    优惠券状态 1待使用，2已使用 3 已过期
     TO_USED(1,"待使用"),USED(2,"已使用"),EXPIRED(3,"已过期");

    private Integer code;

    private String name;

    CouponStateEnums(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    // 普通方法
    public static String getName(int code) {
        for (CouponStateEnums c : CouponStateEnums.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }
}
